<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	
	<!-- END RIBBON -->
	<div class="content">
		<div class="panel panel-default panel-intro">
			<div class="panel-heading">
				<div class="panel-lead">
					<em>
						微信自动回复内容管理
					</em>
					...
				</div>
			</div>
			<div class="panel-body">
				<div id="myTabContent" class="tab-content">
					<div class="tab-pane fade active in" id="one">
						<div class="widget-body no-padding">
							<div class="bootstrap-table">

								<div class="fixed-table-toolbar">
									<div class="bs-bars pull-left">
										<div id="toolbar" class="toolbar">
											<a href="javascript:window.location.reload();" class="btn btn-primary btn-refresh" title="刷新">
												<i class="fa fa-refresh"></i>
                                            </a>
                                            {if condition="$adminController->vif('weixin','auto_add')"}
											<a href="javascript:add('{:url('weixin/auto_add')}');" class="btn btn-success btn-add" title="添加">
												<i class="fa fa-plus"></i> 添加
                                            </a>
                                            {/if}
										</div>
									</div>
									<div class="columns columns-right btn-group pull-right">
										
										<div class="keep-open btn-group" title="列">
											<button type="button" aria-label="columns" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
												<i class="glyphicon glyphicon-th icon-th"></i>
												<span class="caret"></span>
											</button>
											<ul class="dropdown-menu" id="table_menu">
												
											</ul>
										</div>
                                        
									</div>
								</div>
								<div class="fixed-table-container">
									<div class="fixed-table-body">
										<table id="table" class="table table-striped table-bordered table-hover"
										data-operate-edit="1" data-operate-del="1" width="100%">
											<thead>
												<tr>
                                                    <th data-status="1" width="50"><div class="th-inner">ID</div></th>
                                                    <th data-status="1" width="350"><div class="th-inner">关键词</div></th>
													<th data-status="1"><div class="th-inner">回复内容</div></th>
													<th data-status="1" width="50"><div class="th-inner">状态</div></th>
													<th data-status="1" width="60"><div class="th-inner">曝光量</div></th>
													<th data-status="1" width="150"><div class="th-inner">添加时间</div></th>
                                                    <th data-status="1" width="100px"><div class="th-inner">操作</div></th>
												</tr>
											</thead>
                                            
											<tbody>
                                                {volist name="list" id="v"}
                                                <tr class="del-{$v.id}">
                                                    <td align="center">{$v.id}</td>
													<td align="center">{$v.name}</td>
													<td align="center">{$v.content}</td>
                                                    <td align="center">
                                                        {switch name="v.status"}
                                                            {case value="1"}开启{/case}
                                                            {case value="0"}<font color="red">禁用</font>{/case}
                                                        {/switch}
													</td>
													<td align="center">{$v.rates}</td>
													<td align="center">{$v.time|date="Y-m-d H:i:s",###}</td>
                                                    <td align="center">
                                                        {if condition="$adminController->vif('weixin','auto_upd')"}
                                                        <a href="javascript:upd('{:url('weixin/auto_upd', ['id'=>$v['id']])}');" class="btn btn-xs btn-success btn-editone" title="编辑">
                                                            <i class="fa fa-pencil"></i>
                                                        </a>
                                                        {/if}
                                                        {if condition="$adminController->vif('weixin','auto_del')"}
                                                        <button data-id="{$v.id}" class="btn btn-xs btn-danger btn-delone del_weixin" title="删除">
                                                            <i class="fa fa-trash"></i>
                                                        </button>
                                                        {/if}
                                                    </td>
                                                </tr>
                                                {/volist}
                                                <div class="fixed-table-pagination" style="display: block;">
                                                    <div class="pull-left pagination-detail">
                                                        {$page}
                                                    </div>
                                                </div>
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

								
<script>
layui.use(['form'], function(){
  var form = layui.form;
});
// 添加
function add(href) {
	layer.open({
		type: 2,
		title: '添加自动回复内容',
		shadeClose: true,
		shade: false,
		maxmin: true,
		area: ['800px', '500px'],
		btn: ['确认', '取消'],
		content: href,
		yes: function(index, layero) {
			var _this = layero.find('iframe')[0];
			var bool  = _this.contentWindow.doSubimt();
			if (bool !== false) {
				$.thinkmimi({Content : bool['msg'],Type : 1,Align:'right',OutTime:2000,});
				menu_run();
				layer.closeAll();
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		},
	});
}
// 修改
function upd(href) {
	layer.open({
		type: 2,
		title: '修改自动回复内容',
		shadeClose: true,
		shade: false,
		maxmin: true,
		area: ['800px', '500px'],
		btn: ['确认', '取消'],
		content: href,
		yes: function(index, layero) {
			var _this = layero.find('iframe')[0];
			var bool  = _this.contentWindow.doSubimt();
			if (bool !== false) {
				$.thinkmimi({Content : bool['msg'],Type : 1,Align:'right',OutTime:2000,});
				menu_run();
				layer.closeAll();
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		},
	});
}
// 删除
$(".del_weixin").on('click', function(){
    if (confirm('确认删除吗')) {
        var id   = $(this).attr('data-id');
        var data = {'id':id};

        $.ajax({
            type: 'post',
            data:data,
            url: "{:url('weixin/auto_del')}",
            success: function(data) {
                var array = eval('('+data+')');
				if (array['code'] == '01') {
					$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
				} else {
					$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
					$('.del-'+id).remove();
				}
            }
        });
    }
});
</script>
